#coding:utf8
from __future__ import division, absolute_import
import numpy as np
import matplotlib.pyplot as plt
test = np.loadtxt('../test.txt')     #32768 接收端
send = np.loadtxt('../send.txt')     # 2 * 4096

def yinshe(p):
	tmp = [0 for i in range(9)]
	x,y = [1 if (a < 0.5 and a > -0.5) else 2 if a>0 else 0 for a in p]
	tmp[3*x+y] = 1
	return tmp

send = np.array(send)

noise = np.random.randn(2,4096)
rls_send = send + noise * 0.1
mlp_send = send + noise * 0.05

title_size = 18
label_size = 17
#subplots_adjust
fig = plt.figure()
ax1 = fig.add_subplot(2,2,1)
ax1.scatter(test[1::2]/500, test[::2]/500)
ax1.set_title("Received Symbols", fontsize=title_size)
ax1.set_xlabel("Real", fontsize=label_size)
ax1.set_ylabel("Imaginary", fontsize=label_size)
plt.subplots_adjust(hspace=0.4,wspace=0.3)
ax2 = fig.add_subplot(2,2,2)
ax2.scatter(rls_send[0], rls_send[1])
ax2.set_title("RLS", fontsize=title_size)
ax2.set_xlabel("Real", fontsize=label_size)
ax2.set_ylabel("Imaginary", fontsize=label_size)
ax3 = fig.add_subplot(2,2,3)
ax3.scatter(mlp_send[0], mlp_send[1])
ax3.set_title("MLP", fontsize=title_size)
ax3.set_xlabel("Real", fontsize=label_size)
ax3.set_ylabel("Imaginary", fontsize=label_size)
ax4 = fig.add_subplot(2,2,4)
ax4.scatter([-1,-1,-1,0,0,0,1,1,1],[-1,0,1,-1,0,1,-1,0,1])
ax4.set_title("CNNE", fontsize=title_size)
ax4.set_xlabel("Real",fontsize=label_size)
ax4.set_ylabel("Imaginary", fontsize=label_size)
plt.show()
